package a07_ThreadPool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

/**
 * @Author quan
 * @Description 测试自定义的线程池
 * @Date 2023/5/12 20:53
 */
public class a03_MyThreadPoolTest {
    public static void main(String[] args) throws InterruptedException {
        //1、创建一个大小为3的线程池
        a03_MyThreadPool threadPool = new a03_MyThreadPool(3);
        //2、提交任务到线程池
        for (int i = 0; i < 10; i++) {
            int taskId = i;
            //3、表示要执行的任务
            threadPool.submit(()->{
                System.out.println("正在执行任务"+taskId+","+Thread.currentThread().getName());
            });
        }
        //4、等待任务执行
        TimeUnit.SECONDS.sleep(5);
        System.out.println("任务执行结束");
    }
}
